﻿Imports System.Text
Namespace DataMaster
    Public Class clsMSTBARCODERow
        Inherits ADODBU.RowClass
        Private mVar_BARCODE As System.String
        Private mVar_ARTCEXT As System.String
        Private mVar_SIZE As System.String
        Private mVar_COLOR As System.String
        Private mVar_BARTYPE As System.Int32
        Private mVar_BARSTAT As System.Int32
        Private mVar_BARDCRE As System.DateTime
        Private mVar_BARDMAJ As System.DateTime
        Private mVar_BARUTIL As System.String
        Private mVar_BARPROG As System.String
        Private mVar_BARDESCR As System.String
        Private mVar_DirtyBARCODE As Boolean = False
        Private mVar_DirtyARTCEXT As Boolean = False
        Private mVar_DirtySIZE As Boolean = False
        Private mVar_DirtyCOLOR As Boolean = False
        Private mVar_DirtyBARTYPE As Boolean = False
        Private mVar_DirtyBARSTAT As Boolean = False
        Private mVar_DirtyBARDCRE As Boolean = False
        Private mVar_DirtyBARDMAJ As Boolean = False
        Private mVar_DirtyBARUTIL As Boolean = False
        Private mVar_DirtyBARPROG As Boolean = False
        Private mVar_DirtyBARDESCR As Boolean = False
        Private mIsOnInit As Boolean
        Public DataSource As ADODBU.Recordset
        Public RowOrigin As clsMSTBARCODERow
        ''[------------------------------------------------------------------------]'
        Public Sub New()
            RowOrigin = New clsMSTBARCODERow(True)
        End Sub
        ''[------------------------------------------------------------------------]'
        Friend Sub New(lCut As Boolean)
            '--- untuk memutus loop reference 
        End Sub
        ''[------------------------------------------------------------------------]'
        ''' <summary>
        ''' create new this class from inherited of this class or its self
        ''' </summary>
        ''' <param name="recdataRow"></param>
        ''' <remarks></remarks>
        Public Sub New(ByVal recdataRow As ADODBU.RowClass)
            RowOrigin = New clsMSTBARCODERow(True)
            Me.JoinValue(recdataRow)
        End Sub
        ''[------------------------------------------------------------------------]'
        Public Sub New(recData As ADODBU.Recordset)
            RowOrigin = New clsMSTBARCODERow(True)
            DataSource = recData
            Try
                InitVar(recData.GetCurrentDataRow)
            Catch
            End Try
        End Sub

        ''[------------------------------------------------------------------------]'
        Public Sub New(recdataRow As DataRow)
            RowOrigin = New clsMSTBARCODERow(True)
            InitVar(recdataRow)
        End Sub

#Region "Initialize vars "
        ''[------------------------------------------------------------------------]'
        Private Sub InitVar(Fields As DataRow)
            Try
                mVar_BARCODE = Fields("BARCODE")
                RowOrigin.BARCODE = mVar_BARCODE
            Catch e As Exception
            End Try
            Try
                mVar_ARTCEXT = Fields("ARTCEXT")
                RowOrigin.ARTCEXT = mVar_ARTCEXT
            Catch e As Exception
            End Try
            Try
                mVar_SIZE = Fields("SIZE")
                RowOrigin.SIZE = mVar_SIZE
            Catch e As Exception
            End Try
            Try
                mVar_COLOR = Fields("COLOR")
                RowOrigin.COLOR = mVar_COLOR
            Catch e As Exception
            End Try
            Try
                mVar_BARTYPE = Fields("BARTYPE")
                RowOrigin.BARTYPE = mVar_BARTYPE
            Catch e As Exception
            End Try
            Try
                mVar_BARSTAT = Fields("BARSTAT")
                RowOrigin.BARSTAT = mVar_BARSTAT
            Catch e As Exception
            End Try
            Try
                mVar_BARDCRE = Fields("BARDCRE")
                RowOrigin.BARDCRE = mVar_BARDCRE
            Catch e As Exception
            End Try
            Try
                mVar_BARDMAJ = Fields("BARDMAJ")
                RowOrigin.BARDMAJ = mVar_BARDMAJ
            Catch e As Exception
            End Try
            Try
                mVar_BARUTIL = Fields("BARUTIL")
                RowOrigin.BARUTIL = mVar_BARUTIL
            Catch e As Exception
            End Try
            Try
                mVar_BARPROG = Fields("BARPROG")
                RowOrigin.BARPROG = mVar_BARPROG
            Catch e As Exception
            End Try
            Try
                mVar_BARDESCR = Fields("BARDESCR")
                RowOrigin.BARDESCR = mVar_BARDESCR
            Catch e As Exception
            End Try
        End Sub


#End Region
        ''[------------------------------------------------------------------------]'
#Region "Properties"
        Public Property BARCODE As System.String
            Get
                Return mVar_BARCODE
            End Get
            Set(ByVal Value As System.String)
                mVar_BARCODE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("BARCODE"))
                If Not mIsOnInit Then
                    mVar_DirtyBARCODE = True
                End If
            End Set
        End Property
        Public Property ARTCEXT As System.String
            Get
                Return mVar_ARTCEXT
            End Get
            Set(ByVal Value As System.String)
                mVar_ARTCEXT = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTCEXT"))
                If Not mIsOnInit Then
                    mVar_DirtyARTCEXT = True
                End If
            End Set
        End Property
        Public Property SIZE As System.String
            Get
                Return mVar_SIZE
            End Get
            Set(ByVal Value As System.String)
                mVar_SIZE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("SIZE"))
                If Not mIsOnInit Then
                    mVar_DirtySIZE = True
                End If
            End Set
        End Property
        Public Property COLOR As System.String
            Get
                Return mVar_COLOR
            End Get
            Set(ByVal Value As System.String)
                mVar_COLOR = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("COLOR"))
                If Not mIsOnInit Then
                    mVar_DirtyCOLOR = True
                End If
            End Set
        End Property
        Public Property BARTYPE As System.Int32
            Get
                Return mVar_BARTYPE
            End Get
            Set(ByVal Value As System.Int32)
                mVar_BARTYPE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("BARTYPE"))
                If Not mIsOnInit Then
                    mVar_DirtyBARTYPE = True
                End If
            End Set
        End Property
        Public Property BARSTAT As System.Int32
            Get
                Return mVar_BARSTAT
            End Get
            Set(ByVal Value As System.Int32)
                mVar_BARSTAT = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("BARSTAT"))
                If Not mIsOnInit Then
                    mVar_DirtyBARSTAT = True
                End If
            End Set
        End Property
        Public Property BARDCRE As System.DateTime
            Get
                Return mVar_BARDCRE
            End Get
            Set(ByVal Value As System.DateTime)
                mVar_BARDCRE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("BARDCRE"))
                If Not mIsOnInit Then
                    mVar_DirtyBARDCRE = True
                End If
            End Set
        End Property
        Public Property BARDMAJ As System.DateTime
            Get
                Return mVar_BARDMAJ
            End Get
            Set(ByVal Value As System.DateTime)
                mVar_BARDMAJ = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("BARDMAJ"))
                If Not mIsOnInit Then
                    mVar_DirtyBARDMAJ = True
                End If
            End Set
        End Property
        Public Property BARUTIL As System.String
            Get
                Return mVar_BARUTIL
            End Get
            Set(ByVal Value As System.String)
                mVar_BARUTIL = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("BARUTIL"))
                If Not mIsOnInit Then
                    mVar_DirtyBARUTIL = True
                End If
            End Set
        End Property
        Public Property BARPROG As System.String
            Get
                Return mVar_BARPROG
            End Get
            Set(ByVal Value As System.String)
                mVar_BARPROG = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("BARPROG"))
                If Not mIsOnInit Then
                    mVar_DirtyBARPROG = True
                End If
            End Set
        End Property
        Public Property BARDESCR As System.String
            Get
                Return mVar_BARDESCR
            End Get
            Set(ByVal Value As System.String)
                mVar_BARDESCR = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("BARDESCR"))
                If Not mIsOnInit Then
                    mVar_DirtyBARDESCR = True
                End If
            End Set
        End Property
        Public ReadOnly Property BARCODEIsDirty As Boolean
            Get
                Return mVar_DirtyBARCODE
            End Get
        End Property
        Public ReadOnly Property ARTCEXTIsDirty As Boolean
            Get
                Return mVar_DirtyARTCEXT
            End Get
        End Property
        Public ReadOnly Property SIZEIsDirty As Boolean
            Get
                Return mVar_DirtySIZE
            End Get
        End Property
        Public ReadOnly Property COLORIsDirty As Boolean
            Get
                Return mVar_DirtyCOLOR
            End Get
        End Property
        Public ReadOnly Property BARTYPEIsDirty As Boolean
            Get
                Return mVar_DirtyBARTYPE
            End Get
        End Property
        Public ReadOnly Property BARSTATIsDirty As Boolean
            Get
                Return mVar_DirtyBARSTAT
            End Get
        End Property
        Public ReadOnly Property BARDCREIsDirty As Boolean
            Get
                Return mVar_DirtyBARDCRE
            End Get
        End Property
        Public ReadOnly Property BARDMAJIsDirty As Boolean
            Get
                Return mVar_DirtyBARDMAJ
            End Get
        End Property
        Public ReadOnly Property BARUTILIsDirty As Boolean
            Get
                Return mVar_DirtyBARUTIL
            End Get
        End Property
        Public ReadOnly Property BARPROGIsDirty As Boolean
            Get
                Return mVar_DirtyBARPROG
            End Get
        End Property
        Public ReadOnly Property BARDESCRIsDirty As Boolean
            Get
                Return mVar_DirtyBARDESCR
            End Get
        End Property
#End Region
        ''[------------------------------------------------------------------------]'
        Public Function SaveToDataSource() As String
            Dim msgErr As String
            msgErr = ""
            If mVar_DirtyBARCODE Then
                Try
                    DataSource.Fields("BARCODE") = mVar_BARCODE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTCEXT Then
                Try
                    DataSource.Fields("ARTCEXT") = mVar_ARTCEXT
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySIZE Then
                Try
                    DataSource.Fields("SIZE") = mVar_SIZE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyCOLOR Then
                Try
                    DataSource.Fields("COLOR") = mVar_COLOR
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyBARTYPE Then
                Try
                    DataSource.Fields("BARTYPE") = mVar_BARTYPE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyBARSTAT Then
                Try
                    DataSource.Fields("BARSTAT") = mVar_BARSTAT
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyBARDCRE Then
                Try
                    DataSource.Fields("BARDCRE") = Format(mVar_BARDCRE, DataSource.DbConn.DateFormat)
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyBARDMAJ Then
                Try
                    DataSource.Fields("BARDMAJ") = Format(mVar_BARDMAJ, DataSource.DbConn.DateFormat)
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyBARUTIL Then
                Try
                    DataSource.Fields("BARUTIL") = mVar_BARUTIL
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyBARPROG Then
                Try
                    DataSource.Fields("BARPROG") = mVar_BARPROG
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyBARDESCR Then
                Try
                    DataSource.Fields("BARDESCR") = mVar_BARDESCR
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            Return msgErr
        End Function

        ''[------------------------------------------------------------------------]'
        Public Sub ClearDirty()
            mVar_DirtyBARCODE = False
            mVar_DirtyARTCEXT = False
            mVar_DirtySIZE = False
            mVar_DirtyCOLOR = False
            mVar_DirtyBARTYPE = False
            mVar_DirtyBARSTAT = False
            mVar_DirtyBARDCRE = False
            mVar_DirtyBARDMAJ = False
            mVar_DirtyBARUTIL = False
            mVar_DirtyBARPROG = False
            mVar_DirtyBARDESCR = False
        End Sub
        ''[------------------------------------------------------------------------]'
        Public Sub SetDirty()
            mVar_DirtyBARCODE = True
            mVar_DirtyARTCEXT = True
            mVar_DirtySIZE = True
            mVar_DirtyCOLOR = True
            mVar_DirtyBARTYPE = True
            mVar_DirtyBARSTAT = True
            mVar_DirtyBARDCRE = True
            mVar_DirtyBARDMAJ = True
            mVar_DirtyBARUTIL = True
            mVar_DirtyBARPROG = True
            mVar_DirtyBARDESCR = True
        End Sub

    End Class
End Namespace